package 题目集.树.遍历模拟;

import java.util.Scanner;

//https://www.dotcpp.com/oj/contest6308_problem0.html
public class 最大的一层树 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n + 1];
        int[] queue = new int[n + 2];
        int h = 0, t = 0;
        for (int i = 1; i <= n; i++) {
            arr[i] = sc.nextInt();
        }
        int[] size = new int[n + 1];
        size[1] = arr[1];
        int max = 1, min = 1, cnt = 0, level = 1;
        queue[t++] = 1;
        while (h != t) {
            int total = t - h;
            while (total-- > 0) {
                int u = queue[h++];
                size[level] += arr[u];
                int l = u << 1;
                int r = l | 1;
                if (l <= n) {
                    queue[t++] = l;
                }
                if (r <= n) {
                    queue[t++] = r;
                }
            }
            if (size[level] > size[max]) {
                max = level;
                cnt = 1;
            }else if (size[level] == size[max]) {
                cnt++;
            }
            if (size[level] < size[min]) {
                min = level;
            }
            level++;
        }
        if (cnt>1){
            System.out.println(min);
        }else {
            System.out.println(max);
        }
    }
}
